From: Keir Fraser Date: Tue, 12 Jan 2010 07:03:14 +0000 (+0000) Subject: libxenlight: do not try to set memory target with a number we haven't X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12758 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=0d8907b04950b007876f787df51b4cba595cd2ed;p=xen.git libxenlight: do not try to set memory target with a number we haven't verified in set-mem. checking that memory string conversion what done properly instead of sending a request to balloon a domain to 0 memory. Signed-off-by: Vincent Hanquez --- diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c index 2322ce4a67..90896f3e08 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -993,6 +993,8 @@ void set_memory_target(char *p, char *mem) { struct libxl_ctx ctx; uint32_t domid; + uint32_t memorykb; + char *endptr; if (libxl_ctx_init(&ctx, LIBXL_VERSION)) { fprintf(stderr, "cannot init xl context\n"); @@ -1004,7 +1006,13 @@ void set_memory_target(char *p, char *mem) fprintf(stderr, "%s is an invalid domain identifier\n", p); exit(2); } - libxl_set_memory_target(&ctx, domid, atoi(mem)); + memorykb = strtoul(mem, &endptr, 10); + if (*endptr != '\0') { + fprintf(stderr, "invalid memory size: %s\n", mem); + exit(3); + } + printf("setting domid %d memory to : %d\n", domid, memorykb); + libxl_set_memory_target(&ctx, domid, memorykb); } int main_memset(int argc, char **argv)